<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xsl:stylesheet SYSTEM "lang://people">

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
		
	<xsl:include href="../main.xsl" />
	<xsl:include href="menu.xsl" />
	<xsl:include href="../common/navigation.xsl" />
	<xsl:include href="blocks.xsl" />

	<xsl:template match="/data">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
			<link rel="stylesheet" href="{$baseURI}/css/people.css" type="text/css" media="all" />
		</head>
		<body>
			
			<xsl:call-template name="top-userbar" />

			<div id="header">
				<xsl:call-template name="logo" />

				<xsl:call-template name="menu" />
			</div>

			<div id="blocks">
				<div id="blocks_inner">
					<xsl:call-template name="default-blocks-top" />
					
					<div class="stat_block">
						<h4>&labelBlockStat; ↓</h4>
						<div>
							<xsl:apply-templates select="document('xmodule://people/stat')/data/response/gender" mode="block-stat" />
						</div>
					</div>
					
					<div class="stat_block tags">
						<h4>&labelBlockCountries;</h4>
						<div>
							<xsl:apply-templates select="document('xmodule://people/getUsersCountries')/data/response/countries" mode="block-countries" />
						</div>
					</div>
					
					<div class="stat_block tags">
						<h4>&labelBlockCities;</h4>
						<div>
							<xsl:apply-templates select="document('xmodule://people/getUsersCities')/data/response/cities" mode="block-cities" />
						</div>
					</div>
				</div>
			</div>

			<div id="content">
				<div id="content_inner">
					<xsl:apply-templates select="response" />
				</div>
			</div>

			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	<xsl:template match="response">
		<xsl:if test="@search-all = '1'">
			<div id="man_search">
				<form action="{$baseURI}/people/search" method="get">
					<input id="whats_look" type="text" name="word" value="{@search-word}" />
					<xsl:text> </xsl:text>
					<input type="submit" value="&labelSearchButton;" />
				</form>
			</div>
			
			<h1>&labelSearchResults;</h1>
		</xsl:if>
		
		<xsl:if test="count (object) = 0">
			<p>&labelSearchEmpty;.</p>
		</xsl:if>
		
		<xsl:apply-templates select="object[@type='user']" />
		
		<xsl:apply-templates select="pages" mode="pages-navigation">
			<xsl:with-param name="href">
				<xsl:value-of select="$baseURI" />
				<xsl:text>/people/search</xsl:text>
			</xsl:with-param>
			<xsl:with-param name="queryString" select="concat ('?', ../@query-string)"/>
		</xsl:apply-templates>
	</xsl:template>
	
	<xsl:template match="object[@type='user']">
		<xsl:param name="href" select="concat ($baseURI, '/user/', property[@name='login']/value)" />
		<xsl:param name="country" select="property[@name='country']/value" />
		<xsl:param name="city" select="property[@name='city']/value" />
		<xsl:param name="avatar" select="property[@name='avatar']/value" />
		
		<div class="user_search_item">
			<div class="search_user_avatar">
				<a href="{$href}">
					<xsl:if test="$avatar = ''">
						<img src="{$baseURI}/images/default-avatar.png" alt="" />
					</xsl:if>
					<xsl:if test="$avatar != ''">
						<img src="{$baseURI}/thumb_50_50{$avatar}" alt="" />
					</xsl:if>
				</a>
			</div>
			<div class="user_search_body">
				<a class="search_user_username" href="{$href}">
					<xsl:value-of select="property[@name='name']/value" />
				</a>
				<xsl:if test="$country != '' or $city != ''">
					<p>
						<strong>&labelPlace;:</strong>
						<xsl:text> </xsl:text>
						<xsl:value-of select="$city" />
						<xsl:if test="$country != '' and $city != ''">
							<xsl:text>, </xsl:text>
						</xsl:if>
						<xsl:value-of select="$country" />
					</p>
				</xsl:if>
				<xsl:if test="property[@name='about']/value != ''">
					<p>
						<xsl:value-of select="property[@name='about']/value" />
					</p>
				</xsl:if>
			</div>
		</div>
	</xsl:template>
	
</xsl:stylesheet>